package com.itheima.aspect;

import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//切面类(通知类/增强类)，抽取共性代码放到当前类
@Aspect//声明此类是切面类
@Component
public class MyAspect {
    @Pointcut("execution(public * com.itheima.service.impl.*.*(..))")
    public void pt(){

    }
    //@Before("execution(public * com.itheima.service.impl.*.*(..))")
    @Before("pt()")
    public void beforeMethod(){
        //要增强的方法
        System.out.println("执行前置增强方法...");
    }
    //@AfterReturning("execution(public * com.itheima.service.impl.*.*(..))")
    @AfterReturning("pt()")
    public void afterReturning(){
        System.out.println("执行后置增强方法...");
    }
    //@AfterThrowing("execution(public * com.itheima.service.impl.*.*(..))")
    @AfterThrowing("pt()")
    public void afterThrowing(){
        System.out.println("执行异常通知方法...");
    }
    //@After("execution(public * com.itheima.service.impl.*.*(..))")
    @After("pt()")
    public void after(){
        System.out.println("执行最终通知方法...");
    }
    //@Around("execution(public * com.itheima.service.impl.*.*(..))")
    public void aroundMethod(){
        System.out.println("环绕通知...");
    }
}
